<?php

$container_bl=join('&nbsp;', $form->_button_container['BL']);
$container_br=join('&nbsp;', $form->_button_container['BR']);
$container_tr=join('&nbsp;', $form->_button_container['TR']);

if ($form->_status=='delete' || $form->_action=='delete' || $form->_status=='unknow_record'):
	echo $form->output;
else:

if(isset($form->error_string)) echo '<div class="alert">'.$form->error_string.'</div>';
echo $form_scripts;
echo $form_begin;

$usuario=$this->session->userdata['usuario'];
$super=$this->datasis->dameval("SELECT usu_tip FROM usuarios WHERE usu_login='$usuario'");

if($form->_status!='show'){ ?>

<script language="javascript" type="text/javascript">

$(function(){
	$(".inputnum").numeric(".");
	//totalizar();
});

function totalizar (id,count,check){
	 
 var totals=0;
 var totalg=0;
 var cant=0;
 
  
 var deuda = $("#deuda_"+id).val();
  
 var totals = $("#pago_"+id).val();
 
 var monto  = $("#monto").val();
 
 
 if(check==true){
	var pago= $("#pago_"+id).val(deuda);
 }else{
    var pago= $("#pago_"+id).val(0);
 }
  
  totals = parseFloat(totals);
  monto  = parseFloat(monto);
  cant   = parseInt(cant)
  cant=count+1;
 
 for (var i = 1; i < cant; i++) {
	 
     var totals = $("#pago_"+i).val();
     totals = parseFloat(totals);
     totalg += totals;
     //alert(totalg);
     
 }

  

  //ssubt = totals+monto; 
 
 $("#monto").val(totalg);
 $("#monto_val").text(totalg);
 
}
function totalizar_2 (id,count){
	
 var totals=0;
 var totalg=0;
 var cant=0;
  
 var deuda = $("#deuda_"+id).val();
  
 var totals = $("#pago_"+id).val();
 
 var monto  = $("#monto").val();
  
  
  totals = parseFloat(totals);
  monto  = parseFloat(monto);
  cant   = parseInt(cant)
  cant=count+1;
 
  //alert (cant);
  
   
 if(totals>deuda)
  alert('Pago mayor a la DEUDA PENDIENTE, Por favor verifique los montos ');
 
 for (var i = 1; i < cant; i++) {
	 
     var totals = $("#pago_"+i).val();
     totals = parseFloat(totals);
     totalg += totals;
     //alert(totalg);
     
 }
 
 $("#monto").val(totalg);
 $("#monto_val").text(totalg);
}
</script>
<?php } ?>
<table align='center' width="90%" style='background: #EEEEEE'>
	<tr>
		<?php if ($form->_status=='show') { ?>
		<td>
		<a href="#" onClick="window.open('<?php echo base_url() ?>formatos/verhtml/ABONO/AN/<?php echo $form->serie->value ?>/<?php echo $form->numero->value ?>', '_blank', 'width=800, height=600, scrollbars=Yes, status=Yes, resizable=Yes, screenx='+((screen.availWidth/2)-400)+',screeny='+((screen.availHeight/2)-300)+'');" heigth="600" >
		<img src='<?php echo base_url() ?>images/html_icon.gif'></a>
		<a href="#" onClick="window.open('<?php echo base_url() ?>formatos/ver/ABONO/AN/<?php echo $form->serie->value ?>/<?php echo $form->numero->value ?>', '_blank', 'width=800, height=600, scrollbars=Yes, status=Yes, resizable=Yes, screenx='+((screen.availWidth/2)-400)+',screeny='+((screen.availHeight/2)-300)+'');" heigth="600" >
		<img src='<?php echo base_url() ?>images/pdf_logo.gif'></a> Comprobante 
		</td>
	<?php } ?>
	  <td colspan="3" align="right"><?php echo $container_tr?><?php echo $container_br?></td>
  </tr>
</table>
<table align='center' width="90%">
	<tr>
		<td>
         <table align='center' width="100%">
	<tr>
		<td>
		<table width='100%'><tr><td>
		<fieldset style='border: 2px outset #9AC8DA;background: #FFFFFF;'>
		<legend class="titulofieldset" style='color: #2E4B77;'>Informaci&ograve;n del Pago Realizado</legend>
			<table style="margin: 0; width: 100%;">
			<tr>
				<td class="littletableheader"><?php echo $form->serie->label;    ?></td>
				<td colspan="2" class="littletablerow"><strong><?php echo $form->serie->output;   ?>-<?php echo $form->numero->output;   ?></strong></td>
			</tr>
			<tr>
				<td class="littletableheader"><?php echo $form->fecha->label;    ?></td>
				<td colspan="2" class="littletablerow">   <?php echo $form->fecha->output;   ?></td>
			</tr>
			<tr>
				<td class="littletableheader"><?php echo $form->ccosto->label;    ?></td>
				<td colspan="2" class="littletablerow">   <?php echo $form->ccosto->output;   ?></td>
			</tr>
			<tr>
				<td class="littletableheader"><?php echo $form->cuenta->label;    ?></td>
				<td colspan="2" class="littletablerow">   <?php echo $form->cuenta->output;   ?></td>
			</tr>
			<tr>
				<td class="littletableheader"><?php echo $form->cuenta_ori->label;    ?></td>
				<td colspan="2" class="littletablerow">   <?php echo $form->cuenta_ori->output;   ?></td>
			</tr>
			<tr>
			  <td class="littletableheader"><?php echo $form->formap->label     ?></td>
			  <td colspan="2" class="littletablerow"><?php echo $form->formap->output    ?></td>
			</tr>
			<tr>
			  <td class="littletableheader"><?php echo $form->referen->label     ?></td>
			  <td colspan="2" class="littletablerow"><?php echo $form->referen->output    ?></td>
			</tr>
			<tr>
			  <td class="littletableheader"><?php echo $form->cuenta_ori->label     ?></td>
			  <td colspan="2" class="littletablerow"><?php echo $form->cuenta_ori->output    ?></td>
			</tr>
			<tr>
			  <td class="littletableheader"><?php echo $form->condi1->label     ?></td>
			  <td colspan="2" class="littletablerow"><?php echo $form->condi1->output    ?></td>
			</tr>
			</table>
			</fieldset>
		</td><td width="55%">
			<fieldset style='border: 2px outset #9AC8DA;background: #FFFFFF;'>
			<legend  class="titulofieldset" style='color: #2E4B77;'>Identificaci&oacute;n del Cliente </legend>
			<table  style="margin: 0; width: 100%;">
			<tr>
				<td width="33%" class="littletableheader"><?php echo $form->cod_cli->label;  ?></td>
				<td class="littletablerow"><?php echo $form->cod_cli->output; ?></td>
				</tr>
			<tr>
				<td class="littletableheader"><?php echo $form->nombre->label;  ?></td>
				<td class="littletablerow"><?php echo $form->nombre->output;  ?></span></td>
			</tr>
			<tr>
			  <td class="littletableheader"><?php echo $form->rif->label; ?></td>
			  <td class="littletablerow"><?php echo $form->rif->output;   ?></td>
			</tr>
			<tr>
			  <td class="littletableheader"><?php echo $form->moneda->label     ?></td>
			  <td colspan="2" class="littletablerow"><?php echo $form->moneda->output    ?></td>
			</tr>
			<tr>
			  <td class="littletableheader"><?php echo $form->cambio->label     ?></td>
			  <td colspan="2" class="littletablerow"><?php echo $form->cambio->output    ?></td>
			</tr>
			</table>
			</fieldset>
		</td><tr></table>
		<br>		</td>
	</tr>
	<tr>
		<td>
		<div style='overflow:auto;border: 1px solid #9AC8DA;background: #FAFAFA;height:200px'>
		  <table width='70%' border='0' align="center">
            <tr class="littletablerow" align="center">
				<td colspan='10' align='left'>Facturas Aplicadas</td>
            </tr>
            <tr class="littletablerow" align="center">
              <td bgcolor='#527D9E'>Comprobante</td>
              <td bgcolor='#527D9E'>Letra</td>
              <td bgcolor='#527D9E'>Moneda</td>
              <td bgcolor='#527D9E'>Monto</td>
              <td bgcolor='#527D9E'>Numero</td>
              <td bgcolor='#527D9E'>Aplicado el dia</td>
			  <td bgcolor='#527D9E'>Acci&oacute;n</td>
            </tr>
		    <? $i=0; $tmonto=0; foreach ($result AS $items){$i++;?>
            <? $tmonto+=$items->monto ?>
            <tr>
              <td class="littletablerow" align="center">
				  <input type="text"    name="compro[]"  size=1 value="<?=$items->compro?>" readonly="false" />
				  <input type="text"    name="serief[]"  size=3 value="<?=$items->serie?>" readonly="false" />-
				  <input type="text"    name="factura[]"  value="<?=$items->numero?>" size="11" readonly="false" />			   </td>
			   <td align='left' class="littletablerow"><?= $items->letra ?></td>
			   <td align='center' class="littletablerow"><?= $items->nmoneda ?></td>
			   <td align='right' class="littletablerow">	  
				  <input type="text"   name="monto[]" value="<?=$items->monto?>" size="5" readonly="false" />			   </td>
			   <td class="littletablerow" align='left'>L010-<?= $items->numerod ?></td>
			   <td class="littletablerow" align='left'><?= $items->fecha ?></td>
			    <?IF($super=='S'){?>
			    <td align='center' class="littletablerow">	  
				  <a href="<?php echo base_url() ?>/ventas/antic/delete/<?=$form->id->value?>/<?php echo $items->transac ?>"><?php echo img("images/delete.jpg"); ?></a>			   </td> 
			   <?}else{?>
			    <td>&nbsp;</td> 
		       <?}?>      
              </tr>
            <? }?>
            <tr>
              <td colspan='3' align='right' class="littletablerow" ><strong>Totales</strong></td>
              <td align='center' class="littletablerow"><strong><? echo nformat($tmonto) ?></strong></td>
              <td>&nbsp;</td> 
            </tr>
          </table>
		</div>
		<?php echo $container_bl ?>		</td>
	</tr>
	<tr>
		<td>
		<fieldset style='border: 2px outset #9AC8DA;background: #EFEFEF;'>
		<legend  class="titulofieldset" style='color: #2E4B77;' align="right">Resumen de Aplica Anticipo</legend>
		<table width='100%'>
			<tr>
				<td class="littletableheader" width='100'><?php echo $form->condi1->label;    ?></td>
				<td class="littletablerow"    width='643' ><?php echo $form->condi1->output;   ?></td>
				<td align='right' class="littletableheader"><? echo $form->monto->label; ?></td>
				<td width="153" align='right' class="littletablerow"><strong><? echo $form->monto->output; ?></strong></td>
			<tr>
			<tr>

				<td colspan="3" align='right' class="littletableheader">Monto Total Aplicado</td>
				<td width="153" align='right' class="littletablerow"><strong><? echo $form->aplica->output; ?></strong></td>
			</tr>
			<tr>
				<td colspan="3" align='right' class="littletableheader">Monto Por Aplicar</td>
				<td width="153" align='right' class="littletablerow"><strong><? echo nformat($form->monto->output-$form->aplica->output) ?></strong></td>
			<tr>
		</table>
		</fieldset>	
		</td>
	</tr>
</table>

<?php echo $form_end?>
	  <td>
	<tr>
<table>
<?php endif; ?>
